package com.sokal.easycare.modules.position.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sokal.easycare.common.service.CrudService;
import com.sokal.easycare.modules.position.dao.PartyProjDao;
import com.sokal.easycare.modules.position.dao.PartyRoleDao;
import com.sokal.easycare.modules.position.entity.PartyRole;
import com.sokal.easycare.modules.sys.dao.FileLibraryDao;
import com.sokal.easycare.modules.sys.entity.FileLibrary;

/**
 * 岗位人员Service
 * 
 * @author yangmin
 * @version 2017-04-08
 */
@Service
@Transactional(readOnly = true)
public class PartyRoleService extends CrudService<PartyRoleDao, PartyRole> {

	@Autowired
	PartyProjDao ppdao;

	@Autowired
	FileLibraryDao fileDao;

	@Transactional(readOnly = false)
	public void save(PartyRole partyRole, String fileIds[]) {
		partyRole.setState("3");
		super.save(partyRole);
		for (String fileId : fileIds) {
			FileLibrary file = fileDao.get(fileId);
			if (file != null) {
				file.setBId(partyRole.getId());
				fileDao.update(file);
			}
		}
	}

}